<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class login_controller extends admin_controller
{
    public function index()
    {
        //if($this->is_admin_logged()) redirect(base_url(). $this->base_admin_url .'user');
        $data['show_menu'] = 'false';
        $data['action'] = base_url().'login/check-login';
        $this->load->view("admin/master_page/header");
        $this->load->view("admin/login",$data);
        $this->load->view("admin/master_page/footer");

    }

    public function check_login()
    {


        //$username = $this->input->post('username');
        //$password = $this->input->post('password');
        ///$user = $this->user_model->get_element_by_username_and_password($username,$password);

        //if(isset($user->id))
        //{
         //   $this->set_admin_logged($user);
              redirect(base_url(). $this->base_admin_url . 'profile');
        //}
        //else
       // {
       //     $this->unset_admin_logged();
            $data['message'] = 'Sai tên đăng nhập hoặc mật khẩu.';
            $data['action'] = base_url().'login/check-login';
            $this->load->view("admin/master_page/header");
            $this->load->view("admin/login",$data);
            $this->load->view("admin/master_page/footer");
       // }

    }

    public function logout()
    {
        $this->unset_admin_logged();
        redirect(base_url().'ci-admin');

    }

    public function can_this_user_access_this_page()
    {
        return true;
    }
}